package com.wunong.smart.commission.client.query;

import com.wunong.smart.commission.client.enums.CommissionStatusEnum;
import com.wunong.smart.domain.platform.common.BizSource;
import com.wunong.smart.domain.platform.query.QueryDTO;
import com.wunong.smart.domain.platform.utils.ArrayUtils;
import com.wunong.smart.domain.platform.utils.Numbers;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

/**
 * 代办查询对象
 *
 * @author create by zealot.zt
 */
@Getter
@Setter
@ToString(callSuper = true)
public class CommissionQueryDTO extends QueryDTO {

    /**
     * 业务来源信息
     */
    private BizSource source;

    /**
     * 业务编号
     */
    private Long bizId;

    /**
     * 业务类型
     */
    private Integer bizType;

    /**
     * 用户编号
     */
    private Long userId;

    /**
     * 用户角色
     */
    private Integer userRole;

    /**
     * 状态
     *
     * @see CommissionStatusEnum
     */
    private Integer[] statuses;

    /**
     * 代办类型
     */
    private String commissionType;

    public static CommissionQueryDTO of() {
        return new CommissionQueryDTO();
    }

    public void setStatus(Integer status) {
        if (Numbers.isPositive(status)) {
            this.statuses = new Integer[]{status};
        } else {
            this.statuses = null;
        }
    }

    public boolean isEffect() {
        return ArrayUtils.isNotEmpty(statuses)
                || Numbers.isPositive(userId)
                || Numbers.isPositive(bizId)
                || StringUtils.isNotBlank(commissionType);
    }
}
